package com.szholly.pro.watergas_server.ps.controller;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.szholly.pro.watergas_server.common.data.DataUtil;
import com.szholly.pro.watergas_server.common.web.BaseController;
import com.szholly.pro.watergas_server.common.web.RequestUnit;
import com.szholly.pro.watergas_server.ps.service.OnlineMonitorService;
import com.szholly.utils.spring.SpringBeanFactory;
import com.szholly.data.general.GlobalParameter;
import com.szholly.data.general.ITable;
import com.szholly.data.general.ITableFactory;
import com.szholly.data.general.RowBase;
import com.szholly.plug.form.excel.utils.StringUtil;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Controller
@RequestMapping("/DataValidation/*")
public class DataValidationController extends BaseController {
	protected Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	OnlineMonitorService onlineMonitorService;
	
	/**
	 * 保存对比监测审核意见
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/savaCLSH")
	public void savaCLSH(HttpServletResponse resq) {
		HashMap<String, Object> parms = RequestUnit.getHashMapParmO();
		try{
		DataUtil.Create("DATA_VALIDATION_CLSH", parms);
		JSONObject json = new JSONObject();
		json.put("result", "success");
		outString(json.toString());
		}catch(Exception e){
			String msg = e.getMessage();
			outString(msg);
		}
	}
	
	/**
	 * 查询材料审核审核意见
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getCLSH")
	public void getCLSH(HttpServletRequest resq, HttpServletResponse res) throws Exception{
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String CODE=RequestUnit.getParameter("CODE");
		String STATION_ID=RequestUnit.getParameter("STATION_ID");
		
		String sql="select * from DATA_VALIDATION_CLSH where 1=1 ";
		if (CODE != null && !CODE.equals("")) {
			 sql+=" and CODE='"+CODE+"'";
		}
        if (WWTPID != null && !WWTPID.equals("")) {
       	 sql+=" and WWTP_ID='"+WWTPID+"'";
		}
        if (STATION_ID != null && !STATION_ID.equals("")) {
         	 sql+=" and STATION_ID='"+STATION_ID+"'";
  		}
        
        sql+=" order by CLSHTIME";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("DATA_VALIDATION_CLSH");
		String result = DataUtil.getPageSelectJson(sql, parms,pTable);
		outString(result);
	}
	/**
	 * 保存对比监测审核意见
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/savaXCHC")
	public void savaXCHC(HttpServletResponse resq) {
		HashMap<String, Object> parms = RequestUnit.getHashMapParmO();
		try{
			DataUtil.Create("DATA_VALIDATION_XCHC", parms);
			JSONObject json = new JSONObject();
			json.put("result", "success");
			outString(json.toString());
}catch(Exception e){
			String msg = e.getMessage();
			outString(msg);
		}
	}
	/**
	 * 查询对比监测审核意见
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getXCHC")
	public void getXCHC(HttpServletRequest resq, HttpServletResponse res) throws Exception{
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String CODE=RequestUnit.getParameter("CODE");
		String STATION_ID=RequestUnit.getParameter("STATION_ID");
		
		String sql="select * from DATA_VALIDATION_XCHC where 1=1 ";
		if (CODE != null && !CODE.equals("")) {
			 sql+=" and CODE='"+CODE+"'";
		}
        if (WWTPID != null && !WWTPID.equals("")) {
       	 sql+=" and WWTP_ID='"+WWTPID+"'";
		}
        if (STATION_ID != null && !STATION_ID.equals("")) {
         	 sql+=" and STATION_ID='"+STATION_ID+"'";
  		}
        
        sql+=" order by XCHCTIME";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("DATA_VALIDATION_XCHC");
		String result = DataUtil.getPageSelectJson(sql, parms,pTable);
		outString(result);
	}
	/**
	 * 保存对比监测审核意见
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/savaDBJC")
	public void savaDBJC(HttpServletResponse resq) {
		HashMap<String, Object> parms = RequestUnit.getHashMapParmO();
		try{
			DataUtil.Create("DATA_VALIDATION_DBJC", parms);
			JSONObject json = new JSONObject();
			json.put("result", "success");
			outString(json.toString());

}catch(Exception e){
			String msg = e.getMessage();
			outString(msg);
		}
	}
	/**
	 * 查询对比监测审核意见
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getDBJC")
	public void getDBJC(HttpServletRequest resq, HttpServletResponse res) throws Exception{
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String CODE=RequestUnit.getParameter("CODE");
		String STATION_ID=RequestUnit.getParameter("STATION_ID");
		
		String sql="select * from DATA_VALIDATION_DBJC where 1=1 ";
		if (CODE != null && !CODE.equals("")) {
			 sql+=" and CODE='"+CODE+"'";
		}
        if (WWTPID != null && !WWTPID.equals("")) {
       	 sql+=" and WWTP_ID='"+WWTPID+"'";
		}
        if (STATION_ID != null && !STATION_ID.equals("")) {
         	 sql+=" and STATION_ID='"+STATION_ID+"'";
  		}
        
        sql+=" order by DBJCTIME";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("DATA_VALIDATION_DBJC");
		String result = DataUtil.getPageSelectJson(sql, parms,pTable);
		outString(result);
	}
	/**
	 * 保存企业自检审核意见
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/savaQYZJ")
	public void savaQYZJ(HttpServletResponse resq) {
		HashMap<String, Object> parms = RequestUnit.getHashMapParmO();
		try{
			DataUtil.Create("DATA_VALIDATION_QYZJ", parms);
		outString("success");
		JSONObject json = new JSONObject();
		json.put("result", "success");
		outString(json.toString());

}catch(Exception e){
		String msg = e.getMessage();
		outString(msg);
	}
	}
	/**
	 * 查询企业自检审核意见
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getQYZJ")
	public void getQYZJ(HttpServletRequest resq, HttpServletResponse res) throws Exception{
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String CODE=RequestUnit.getParameter("CODE");
		String STATION_ID=RequestUnit.getParameter("STATION_ID");
		
		String sql="select * from DATA_VALIDATION_QYZJ where 1=1 ";
		if (CODE != null && !CODE.equals("")) {
			 sql+=" and CODE='"+CODE+"'";
		}
        if (WWTPID != null && !WWTPID.equals("")) {
       	 sql+=" and WWTP_ID='"+WWTPID+"'";
		}
        if (STATION_ID != null && !STATION_ID.equals("")) {
         	 sql+=" and STATION_ID='"+STATION_ID+"'";
  		}
        
        sql+=" order by QYZJTIME";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("DATA_VALIDATION_QYZJ");
		String result = DataUtil.getPageSelectJson(sql, parms,pTable);
		outString(result);
	}
	/**
	 * 保存自检材料审核意见
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/savaZJCL")
	public void savaZJCL(HttpServletResponse resq) {
		HashMap<String, Object> parms = RequestUnit.getHashMapParmO();
		try{
			DataUtil.Create("DATA_VALIDATION_ZJCL", parms);
			JSONObject json = new JSONObject();
			json.put("result", "success");
			outString(json.toString());

		}catch(Exception e){
			String msg = e.getMessage();
			outString(msg);
		}
	}
	/**
	 * 查询自检材料审核意见
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getZJCL")
	public void getZJCL(HttpServletRequest resq, HttpServletResponse res) throws Exception{
		String WWTPID=RequestUnit.getParameter("WWTPID");
		//String CODE=RequestUnit.getParameter("CODE");
		String STATION_ID=RequestUnit.getParameter("STATION_ID");
		
		String sql="select * from DATA_VALIDATION_ZJCL where 1=1 ";
		/*if (CODE != null && !CODE.equals("")) {
			 sql+=" and CODE='"+CODE+"'";
		}*/
        if (WWTPID != null && !WWTPID.equals("")) {
       	 sql+=" and WWTP_ID='"+WWTPID+"'";
		}
        if (STATION_ID != null && !STATION_ID.equals("")) {
         	 sql+=" and STATION_ID='"+STATION_ID+"'";
  		}
        
        sql+=" order by ZJCLTIME";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("DATA_VALIDATION_ZJCL");
		String result = DataUtil.getPageSelectJson(sql, parms,pTable);
		outString(result);
	}
	/**
	 * 获取数据审核历史记录
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getDataValidationHistory")
	public void getDataValidationHistory(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String CODE=RequestUnit.getParameter("CODE");
		String GUID=RequestUnit.getParameter("GUID");
		String st=RequestUnit.getParameter("st");
		String et=RequestUnit.getParameter("et");
		String sql="select * from DATA_VALIDATION_COMPARE where 1=1 ";
		if (CODE != null && !CODE.equals("")) {
			 sql+=" and CODE='"+CODE+"'";
		}
		if (GUID != null && !GUID.equals("")) {
			 sql+=" and GUID='"+GUID+"'";
		}
        if (WWTPID != null && !WWTPID.equals("")) {
        	 sql+=" and WWTP_ID='"+WWTPID+"'";
		}
        if (st != null && !st.equals("")) {
        	 sql+=" and (code like '"+st+"%'";
		}
        if (et != null && !et.equals("")) {
        	 sql+=" or code like '"+et+"%')";
		}
         sql+=" order by CODE";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("DATA_VALIDATION_COMPARE");
		String result = DataUtil.getPageSelectJson(sql, parms,pTable);
		outString(result);
	}
	/**
	 * 保存每季度记录
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/updateDataValidation")
	public void updateDataValidation(HttpServletResponse resq) {
		HashMap<String, Object> parms = RequestUnit.getHashMapParmO();
		try{
				DataUtil.Create("DATA_VALIDATION_COMPARE", parms);
				JSONObject json = new JSONObject();
				json.put("result", "success");
				outString(json.toString());
		
		}catch(Exception e){
				String msg = e.getMessage();
				outString(msg);
		}
	}
	/**
	 * 获取数据审核内容描述
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getDecriptionList")
	public void getDecriptionList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String sql="select * from DATA_VALIDATION_DESCRIPTION";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		String result = DataUtil.getPageSelectJson(sql, parms);
		outString(result);
	}
	/**
	 * 获取文档数据
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getFilelList")
	public void getFilelList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		//String CODE=RequestUnit.getParameter("CODE");
		String flowType=RequestUnit.getParameter("flowType");
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		String validatasql=	"select t1.*\n" +
						"  from COMPANY_FILE t1\n" + 
						"  left join BC_SITE_INFO t2 on t1.wwtp_id = t2.wwtp_id\n" + 
						" where 1 = 1";

		String acceptancesql="select t1.*\n" +
						"  from BC_DEVICE_ACCE_INFO t1\n" + 
						"  left join BC_SITE_INFO t2 on t1.station_code = t2.exp_no where 1 = 1 ";
		if (WWTPID != null && !WWTPID.equals("")) {
			validatasql += " and t2.WWTP_ID =@WWTP_ID";
       	    acceptancesql += " and t2.WWTP_ID =@WWTP_ID";
        	parms.add(new GlobalParameter("WWTP_ID",WWTPID) );
		}
		if (flowType != null && !flowType.equals("")) {
			validatasql+=" and t2.flow_type =@flowType";
       	    acceptancesql+=" and t2.flow_type =@flowType";
         	parms.add(new GlobalParameter("flowType",flowType) );
		}
		//List<RowBase> list= DataUtil.getSelectRows(validatasql, parms);
		List<RowBase> list1= DataUtil.getSelectRows(acceptancesql, parms);
		String PFWJ=""; //环保部门关于安装污染源自动监控设施批复的文件
		String GFQRWJ=""; //排污口规范化及点位确认文件
		String TSSYXBG=""; //安装调试与试运行报告
		String LWBG=""; //联网报告
		String SYXJCBG=""; //适用性监测报告
		String GLZD=""; //相关管理制度
		String WTYYHT=""; //委托运营合同
		//String B01=""; //《国家重点监控企业污染源自动监控设施验收表》
		//String B07="";  //设备仪器生产厂设备使用说明书
		//String B10 ="";//监控设备与数据采集仪的通讯协议
		//String B11="";  //自动监控设备在企业排污口设计、安装技术文件资料（自动监测设备布置图，管理布置图和数据采集及自动控制图）
		//String B12=""; //产品的生产工艺流程简图和排污节点图、污染源治理工艺流程图和排污管线布置图
		if(list1.size()>0){
			if(list1.get(0).getValue("PFWJ")!=null){
				PFWJ=list1.get(0).getValue("PFWJ").toString();
			}
			if(list1.get(0).getValue("GFQRWJ")!=null){
				GFQRWJ=list1.get(0).getValue("GFQRWJ").toString();
			}
			if(list1.get(0).getValue("TSSYXBG")!=null){
				TSSYXBG=list1.get(0).getValue("TSSYXBG").toString();
			}
			if(list1.get(0).getValue("LWBG")!=null){
				LWBG=list1.get(0).getValue("LWBG").toString();
			}
			if(list1.get(0).getValue("SYXJCBG")!=null){
				SYXJCBG=list1.get(0).getValue("SYXJCBG").toString();
			}
			if(list1.get(0).getValue("GLZD")!=null){
				GLZD=list1.get(0).getValue("GLZD").toString();
			}
			if(list1.get(0).getValue("WTYYHT")!=null){
				WTYYHT=list1.get(0).getValue("WTYYHT").toString();
			}
		}
		/*if(list1.size()>0){
			B01=list.get(0).getValue("B01").toString();
			B07=list.get(0).getValue("B07").toString();
			B10=list.get(0).getValue("B10").toString();
			B11=list.get(0).getValue("B11").toString();
			B12=list.get(0).getValue("B12").toString();
		}*/
		HashMap<String, String> hdata = new HashMap<>();
		hdata.put("PFWJ", PFWJ);
		hdata.put("GFQRWJ", GFQRWJ);
		hdata.put("TSSYXBG", TSSYXBG);
		hdata.put("LWBG", LWBG);
		hdata.put("SYXJCBG", SYXJCBG);
		hdata.put("GLZD", GLZD);
		hdata.put("WTYYHT", WTYYHT);
		/*hdata.put("B01", B01);
		hdata.put("B07", B07);
		hdata.put("B10", B10);
		hdata.put("B11", B11);
		hdata.put("B12", B12);*/
		List<HashMap<String, String>> ListArray = new ArrayList<>();
		ListArray.add(hdata);
		JSONArray dataArray=JSONArray.fromObject(ListArray);
		JSONObject resultJson = DataUtil.getSelectJsonObject(validatasql, parms,null);
		resultJson.put("hsdata", dataArray);
		outString(resultJson.toString());
	}
	
	/**
	 * 上传文档数据
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/updateFile")
	public void updateFile(HttpServletResponse resq) {
		HashMap<String, Object> parms = RequestUnit.getHashMapParmO();
		String CODE=RequestUnit.getParameter("CODE");
		String WWTPID = parms.get("WWTP_ID").toString();
		String sql="select * from COMPANY_FILE where WWTP_ID='"+WWTPID+"' and CODE='"+CODE+"'";
		List<GlobalParameter> parm = new ArrayList<>();
		List<RowBase> list = DataUtil.getSelectRows(sql, parm);
		try{
		if (list.isEmpty()) {
			DataUtil.Create("COMPANY_FILE", parms);
		} else {
			DataUtil.Update("COMPANY_FILE", parms);
		}
		JSONObject json = new JSONObject();
		json.put("result", "success");
		outString(json.toString());

}catch(Exception e){
		String msg = e.getMessage();
		outString(msg);
	}
	}
	/**
	 * 获取运行与维护数据
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getSelfTestList")
	public void getSelfTestList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String yearValue= RequestUnit.getParameter("yearValue");
		String quarterValue= RequestUnit.getParameter("quarterValue");
		String flowType=RequestUnit.getParameter("flowType");
		String endtime="";
		String satrttime="";
		if(quarterValue.equals("1")){
			satrttime=yearValue+"-01-01 00:00:00";
			endtime=yearValue+"-03-31 23:59:59";
		}
		if(quarterValue.equals("2")){
			satrttime=yearValue+"-04-01 00:00:00";
			endtime=yearValue+"-06-30 23:59:59";
		}
		if(quarterValue.equals("3")){
			satrttime=yearValue+"-07-01 00:00:00";
			endtime=yearValue+"-09-30 23:59:59";
		}
		if(quarterValue.equals("4")){
			satrttime=yearValue+"-10-01 00:00:00";
			endtime=yearValue+"-12-31 23:59:59";
		}
		String sql1 = " select case when t.INSPECTION_SUM>11 then '是'  else '否' end INSPECTION_SUM  from (select   count(*)   as INSPECTION_SUM from OP_INSP_RECORD t1 left join OPERATION_TASK t2 on t1.task_code=t2.task_code "
				+ "  left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no where t2.TASK_STATUS='1' and t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
				+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss'))t";//日常巡检记录
		
		String sql2 = " select case when t.MAINTAINANCE_SUM>11 then '是'  else '否' end MAINTAINANCE_SUM  from (select count(*)  as MAINTAINANCE_SUM from OP_MAIN_RECORD t1 left join OPERATION_TASK t2 on t1.task_code=t2.task_code"
				+ " left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no where t2.TASK_STATUS='1' and t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
				+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss'))t";//定期维护
		
		String sql3 = " select (CASE count(*)  WHEN 0 THEN '否'    ELSE '是' END) as FAILURE_SUM from OP_FAILURE_REPAIR t1 left join OPERATION_TASK t2 on t1.TASK_ID=t2.task_code"
				+ " left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no where t2.TASK_STATUS='1' and t1.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
				+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";//设备故障维修
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		String str1=DataUtil.getScale(sql1, parms).toString();
		String str2=DataUtil.getScale(sql2, parms).toString();
		String str3=DataUtil.getScale(sql3, parms).toString();
		HashMap<String, String> hdata = new HashMap<>();
		hdata.put("ZFFZSB", str1);
		hdata.put("RCXJ", str2);
		hdata.put("JX", str3);
		
		List<HashMap<String, String>> staticList = new ArrayList<>();
		staticList.add(hdata);
		JSONArray staticdata=JSONArray.fromObject(staticList);
		JSONObject resultJson=new JSONObject();
		resultJson.put("data", staticdata);
		outString(resultJson.toString());
		
	}
	/**
	 * 获取运行与维护数据详情记录
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/OpenYxywhDetail")
	public void OpenYxywhDetail(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String yearValue= RequestUnit.getParameter("yearValue");
		String quarterValue= RequestUnit.getParameter("quarterValue");
		String flowType=RequestUnit.getParameter("flowType");
		String TYPE=RequestUnit.getParameter("TYPE");
		String endtime="";
		String satrttime="";
		if(quarterValue.equals("1")){
			satrttime=yearValue+"-01-01 00:00:00";
			endtime=yearValue+"-03-31 23:59:59";
		}
		if(quarterValue.equals("2")){
			satrttime=yearValue+"-04-01 00:00:00";
			endtime=yearValue+"-06-30 23:59:59";
		}
		if(quarterValue.equals("3")){
			satrttime=yearValue+"-07-01 00:00:00";
			endtime=yearValue+"-09-30 23:59:59";
		}
		if(quarterValue.equals("4")){
			satrttime=yearValue+"-10-01 00:00:00";
			endtime=yearValue+"-12-31 23:59:59";
		}
		String sql="";
		if(TYPE.equals("A")){
			sql="select t1.a01,t1.a02,t1.a03,t1.a04,t1.a05,t1.a06,t1.a07,t1.a08 from OP_INSP_RECORD t1 left join OPERATION_TASK t2 on t1.task_code=t2.task_code left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no "
					+" where t2.TASK_STATUS='1' and t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
					+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		}
		if(TYPE.equals("B")){
			sql="select t1.b01,t1.b02,t1.b03,t1.b04,t1.b05,t1.b06,t1.b07,t1.b08 from OP_INSP_RECORD t1 left join OPERATION_TASK t2 on t1.task_code=t2.task_code left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no "
					+" where t2.TASK_STATUS='1' and t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
					+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		}
		if(TYPE.equals("C")){
			sql="select t1.c01,t1.c02,t1.c03,t1.c04,t1.c05,t1.c06,t1.c07,t1.c08,t1.c09,t1.c10,t1.c21,t1.c22,t1.c23,t1.c24,t1.c25,t1.c31,t1.c32,t1.c33,t1.c34,t1.c35 from OP_INSP_RECORD t1 left join OPERATION_TASK t2 on t1.task_code=t2.task_code left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no "
					+" where t2.TASK_STATUS='1' and t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
					+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		}
		if(TYPE.equals("D")){
			sql="select t1.d01,t1.d02,t1.d03,t1.d04,t1.d05,t1.d06,t1.d11,t1.d12,t1.d13,t1.d14,t1.d15,t1.d16 from OP_INSP_RECORD t1 left join OPERATION_TASK t2 on t1.task_code=t2.task_code left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no "
					+" where t2.TASK_STATUS='1' and t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
					+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		}
		if(TYPE.equals("F")){
			sql = "select t2.name as DEVICE_NAMED ,t1.*,t3.name from  OP_FAILURE_REPAIR t1  "
                    +" left join BC_SITE_INFO t3 on t1.station_id=t3.exp_no left join BC_SITE_DEVICE_RPT  t2  on t1.DEVICE_NUMBER=t2.device_typenum  "
                    +" where  t1.WWTP_ID='"+WWTPID+"' and t3.flow_type='"+flowType
                    +"' and t1.CREATE_TIME >= to_date('"+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
			/*sql = "select t1.*,t3.name from  OP_FAILURE_REPAIR t1 left join BC_SITE_DEVICE_RPT  t2  on t1.DEVICE_NUMBER=t2.device_typenum "
                    +" left join BC_SITE_INFO t3 on t1.station_id=t3.exp_no left join BC_SITE_POLL  t4 on t3.exp_no=t4.site_id "
                    +" where t1.WWTP_ID='"+WWTPID+"' and t3.flow_type='"+flowType
                    +"' and t1.CREATE_TIME >= to_date('"+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";*/
		}
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("TASKQUERYDIC");
		String result = DataUtil.getPageSelectJson(sql, parms, pTable);
		outString(result);
	}
	/**
	 * 获取质量保证和质量控制数据
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getzlbzhkzList")
	public void getzlbzhkzList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String yearValue= RequestUnit.getParameter("yearValue");
		String quarterValue= RequestUnit.getParameter("quarterValue");
		String flowType=RequestUnit.getParameter("flowType");
		String endtime="";
		String satrttime="";
		if(quarterValue.equals("1")){
			satrttime=yearValue+"-01-01 00:00:00";
			endtime=yearValue+"-03-31 23:59:59";
		}
		if(quarterValue.equals("2")){
			satrttime=yearValue+"-04-01 00:00:00";
			endtime=yearValue+"-06-30 23:59:59";
		}
		if(quarterValue.equals("3")){
			satrttime=yearValue+"-07-01 00:00:00";
			endtime=yearValue+"-09-30 23:59:59";
		}
		if(quarterValue.equals("4")){
			satrttime=yearValue+"-10-01 00:00:00";
			endtime=yearValue+"-12-31 23:59:59";
		}
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		String sql1 = " select   t1.*   from OP_STAND_VERI t1 left join OPERATION_TASK t2 on t1.task_code=t2.task_code "
				+ "  left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no where t2.TASK_STATUS='1' and t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
				+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		String sql2 = " select   t1.*   from OP_SAMPLE_COMP t1 left join OPERATION_TASK t2 on t1.TASK_ID=t2.task_code "
				+ "  left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no where t2.TASK_STATUS='1' and t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
				+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		
		//获取设备污染物数目
		String sql3="select t1.name from BC_SITE_POLL t1 left join BC_SITE_INFO t2 on t1.site_id=t2.exp_no where t2.WWTP_ID='"
				   +WWTPID+"'and t2.flow_type='"+flowType+"'";
		List<RowBase> list = DataUtil.getSelectRows(sql3, parms);
		int num=list.size();
		int sum=num*3*3;//应有这么多条数据 参数*一个参数一个月三条*三个月
		HashMap<String, String> hdata = new HashMap<>();
		String bzrystr="";
		String sybdstr="";
		List<RowBase> listbzry = DataUtil.getSelectRows(sql1, parms);
		int bzrynum=listbzry.size();
		List<RowBase> listsybd = DataUtil.getSelectRows(sql2, parms);
		int sybdnum=listsybd.size();
		if(bzrynum>=sum){
			bzrystr="是";
		}
		else{
			bzrystr="否";
		}
		if(sybdnum>=sum){
			sybdstr="是";
		}
		else{
			sybdstr="否";
		}
		hdata.put("BZRY", bzrystr);
		hdata.put("SYBD", sybdstr);
		List<HashMap<String, String>> staticList = new ArrayList<>();
		staticList.add(hdata);
		JSONArray staticdata=JSONArray.fromObject(staticList);
		JSONObject resultJson=new JSONObject();
		resultJson.put("data", staticdata);
		outString(resultJson.toString());
	}
	/**
	 * 获取质量保证和质量控制记录
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getzlbzhkzDetail")
	public void getzlbzhkzDetail(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String yearValue= RequestUnit.getParameter("yearValue");
		String quarterValue= RequestUnit.getParameter("quarterValue");
		String flowType=RequestUnit.getParameter("flowType");
		String type=RequestUnit.getParameter("TYPE");
		String endtime="";
		String satrttime="";
		if(quarterValue.equals("1")){
			satrttime=yearValue+"-01-01 00:00:00";
			endtime=yearValue+"-03-31 23:59:59";
		}
		if(quarterValue.equals("2")){
			satrttime=yearValue+"-04-01 00:00:00";
			endtime=yearValue+"-06-30 23:59:59";
		}
		if(quarterValue.equals("3")){
			satrttime=yearValue+"-07-01 00:00:00";
			endtime=yearValue+"-09-30 23:59:59";
		}
		if(quarterValue.equals("4")){
			satrttime=yearValue+"-10-01 00:00:00";
			endtime=yearValue+"-12-31 23:59:59";
		}
		String sql="";
		if(type.equals("A")){
			 sql = " select   t1.*   from OP_STAND_VERI t1 left join OPERATION_TASK t2 on t1.task_code=t2.task_code "
					+ "  left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no where t2.TASK_STATUS='1' and t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
					+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		}
		if(type.equals("B")){
			 sql = " select   t1.*   from OP_SAMPLE_COMP t1 left join OPERATION_TASK t2 on t1.TASK_ID=t2.task_code "
						+ "  left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no where t2.TASK_STATUS='1' and t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
						+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		}
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("TASKQUERYDIC");
		String result = DataUtil.getPageSelectJson(sql, parms, pTable);
		outString(result);
	}
	/**
	 * 获取数据准确性数据
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getsjzqxList")
	public void getsjzqxList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String yearValue= RequestUnit.getParameter("yearValue");
		String quarterValue= RequestUnit.getParameter("quarterValue");
		String flowType=RequestUnit.getParameter("flowType");
		String endtime="";
		String satrttime="";
		if(quarterValue.equals("1")){
			satrttime=yearValue+"-01-01 00:00:00";
			endtime=yearValue+"-03-31 23:59:59";
		}
		if(quarterValue.equals("2")){
			satrttime=yearValue+"-04-01 00:00:00";
			endtime=yearValue+"-06-30 23:59:59";
		}
		if(quarterValue.equals("3")){
			satrttime=yearValue+"-07-01 00:00:00";
			endtime=yearValue+"-09-30 23:59:59";
		}
		if(quarterValue.equals("4")){
			satrttime=yearValue+"-10-01 00:00:00";
			endtime=yearValue+"-12-31 23:59:59";
		}
		//设备验收语句
		String sql1 = " select  t1.* from BC_DEVICE_ACCE_INFO t1  "
				+ "  left join BC_SITE_INFO t2 on t1.station_code=t2.exp_no where t1.WSCLC_ID='"+WWTPID+"' and t2.FLOW_TYPE='"+flowType+"' and t1.STATUS='1' and t1.CREATE_TIME >= to_date('"
				+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')"
				+" and t1.pfwj is not null and t1.gfqrwj is not null and t1.TSSYXBG is not null and t1.LWBG is not null and t1.SYXJCBG is not null and t1.GLZD is not null  and t1.WTYYHT is not null";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		//String str1=DataUtil.getScale(sql1, parms).toString();
		String str1="";
		List<RowBase> list = DataUtil.getSelectRows(sql1, parms);//验收记录
		if(list.size()>0){
			str1="是";
		}
		else{
			str1="否";
		}
		//水样比对语句
		String sql2 = " select   t1.*   from OP_SAMPLE_COMP t1 left join OPERATION_TASK t2 on t1.TASK_ID=t2.task_code "
				+ "  left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no where t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
				+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		List<RowBase> listsybd = DataUtil.getSelectRows(sql2, parms);
		int sybdnum=listsybd.size();
		//质控样试验语句
		String sql4=" select   t1.*   from OP_STAND_VERI t1 left join OPERATION_TASK t2 on t1.task_code=t2.task_code "
				+ "  left join BC_SITE_INFO t3 on t2.station_id=t3.exp_no where t3.wwtp_id='"+WWTPID+"' and t3.FLOW_TYPE='"+flowType+"' and t1.CREATE_TIME >= to_date('"
				+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		List<RowBase> listzysy = DataUtil.getSelectRows(sql4, parms);
		int zysynum=listzysy.size();
		String valueone="";//质控样品浓度1
		String valuetwo="";//质控样品浓度2
		String ERRORONE="";//相对误差1
		String ERRORTWO="";//相对误差2
		String gone="";//打开详情显示变色
		String gtwo="";//打开详情显示变色
		String gthree="";//水样比对变色
		String ERRORTHREE="";//水样比对相对误差值
		if(listzysy.size()>1){
			
			 valueone=listzysy.get(0).getValue("AUTO_RESULT").toString()+"mg/L";
			 valuetwo=listzysy.get(1).getValue("AUTO_RESULT").toString()+"mg/L";
			 ERRORONE=(Float.parseFloat(listzysy.get(0).getValue("OPPOSITE_ERROR").toString())*100)+"%";
			 ERRORTWO=(Float.parseFloat(listzysy.get(1).getValue("OPPOSITE_ERROR").toString())*100)+"%";
			 gone=listzysy.get(0).getValue("GUID").toString();
			 gtwo=listzysy.get(1).getValue("GUID").toString();
		}
         if(listsybd.size()>0){
        	 gthree=listsybd.get(0).getValue("GUID").toString();
        	 ERRORTHREE=(Float.parseFloat(listsybd.get(0).getValue("MEASURE_DEVIATION").toString())*100)+"%";
		}
		 /*if(listzysy.size()>0){
			valueone=listzysy.get(0).getValue("AUTO_RESULT").toString()+"mg/L";
			 valuetwo=listzysy.get(0).getValue("AUTO_RESULT").toString()+"mg/L";
			 ERRORONE=(Float.parseFloat(listzysy.get(0).getValue("OPPOSITE_ERROR").toString())*100)+"%";
			 ERRORTWO=(Float.parseFloat(listzysy.get(0).getValue("OPPOSITE_ERROR").toString())*100)+"%";
			 gone=listzysy.get(0).getValue("GUID").toString();
			 gtwo=listzysy.get(0).getValue("GUID").toString();
		}
		if(listsybd.size()>1){
			
		}*/
		
		//污染物数目语句
		String sql3="select t1.name from BC_SITE_POLL t1 left join BC_SITE_INFO t2 on t1.site_id=t2.exp_no where t2.WWTP_ID='"
				   +WWTPID+"'and t2.flow_type='"+flowType+"'";
		List<RowBase> listq = DataUtil.getSelectRows(sql3, parms);
		int num=listq.size();
		int sum=num*3*3;//应有这么多条数据 参数*一个参数一个月三条*三个月
		String sybdstr="";
		String zysystr="";
		if(sybdnum>=sum){
			sybdstr="是";
		}
		else{
			sybdstr="否";
		}
		if(zysynum>=sum){
			zysystr="是";
		}
		else{
			zysystr="否";
		}
		
		HashMap<String, String> hdata1 = new HashMap<>();
		hdata1.put("NAME", "在线监测设备验收");
		hdata1.put("DESCRIPTION", "是否已经验收，并提供检测报告和验收报告");
		hdata1.put("SUM", str1);
		hdata1.put("SYBD", sybdstr);
		hdata1.put("ZKSY", zysystr);
		hdata1.put("VALUEONE", valueone);
		hdata1.put("VALUETWO", valuetwo);
		hdata1.put("ERRORONE", ERRORONE);
		hdata1.put("ERRORTWO", ERRORTWO);
		hdata1.put("GONE", gone);
		hdata1.put("GTWO", gtwo);
		hdata1.put("GTHREE", gthree);
		hdata1.put("ERRORTHREE", ERRORTHREE);
		
		List<HashMap<String, String>> staticList = new ArrayList<>();
		staticList.add(hdata1);
		JSONArray staticdata=JSONArray.fromObject(staticList);
		JSONObject resultJson=new JSONObject();
		resultJson.put("data", staticdata);
		outString(resultJson.toString());
	}
	/**
	 * 获取数据准确性数据记录
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getsjzqxDetail")
	public void getsjzqxDetail(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String yearValue= RequestUnit.getParameter("yearValue");
		String quarterValue= RequestUnit.getParameter("quarterValue");
		String flowType=RequestUnit.getParameter("flowType");
		String type=RequestUnit.getParameter("TYPE");
		String endtime="";
		String satrttime="";
		if(quarterValue.equals("1")){
			satrttime=yearValue+"-01-01 00:00:00";
			endtime=yearValue+"-03-31 23:59:59";
		}
		if(quarterValue.equals("2")){
			satrttime=yearValue+"-04-01 00:00:00";
			endtime=yearValue+"-06-30 23:59:59";
		}
		if(quarterValue.equals("3")){
			satrttime=yearValue+"-07-01 00:00:00";
			endtime=yearValue+"-09-30 23:59:59";
		}
		if(quarterValue.equals("4")){
			satrttime=yearValue+"-10-01 00:00:00";
			endtime=yearValue+"-12-31 23:59:59";
		}
		String sql ="";
		if(type.equals("A")){
		 sql = " select  t1.*,t2.name from BC_DEVICE_ACCE_INFO t1  "
				+ "  left join BC_SITE_INFO t2 on t1.station_code=t2.exp_no where t1.WSCLC_ID='"+WWTPID+"' and t2.FLOW_TYPE='"+flowType+"' and t1.STATUS='1' and t1.ACCEP_DATE >= to_date('"
				+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.ACCEP_DATE <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
				
		}
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("TASKQUERYDIC");
		String result = DataUtil.getPageSelectJson(sql, parms, pTable);
		outString(result);
	}
	/**
	 * 获取设备运转率数据
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getsbyzlList")
	public void getsbyzlList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String yearValue= RequestUnit.getParameter("yearValue");
		String quarterValue= RequestUnit.getParameter("quarterValue");
		String flowType=RequestUnit.getParameter("flowType");
		String endtime="";
		String satrttime="";
		 int num=0;
		 int num1=0;
		 int num2=0;
		 int num3=0;
		 int hour=0;
		 int a=0;
		 int b=1;
		 int c=2;
		if(quarterValue.equals("1")){
			satrttime=yearValue+"-01-01 00:00:00";
			endtime=yearValue+"-03-31 23:59:59";
			a=0;
			b=1;
			c=2;
		}
		if(quarterValue.equals("2")){
			satrttime=yearValue+"-04-01 00:00:00";
			endtime=yearValue+"-06-30 23:59:59";
			a=3;
			b=4;
			c=5;
		}
		if(quarterValue.equals("3")){
			satrttime=yearValue+"-07-01 00:00:00";
			endtime=yearValue+"-09-30 23:59:59";
			a=6;
			b=7;
			c=8;
		}
		if(quarterValue.equals("4")){
			satrttime=yearValue+"-10-01 00:00:00";
			endtime=yearValue+"-12-31 23:59:59";
			a=9;
			b=10;
			c=11;
			
		}
		num1=getMonthDay(yearValue,a);
		num2=getMonthDay(yearValue,b);
		num3=getMonthDay(yearValue,c);
		//每个季度的小时数
		hour=(num1+num2+num3)*24;
		//CODcr查询语句
		String sql1 = "select t1.begin_time,t1.end_time from    OP_FAILURE_REPAIR t1 left join BC_SITE_DEVICE_RPT  t2  on t1.DEVICE_NUMBER=t2.device_typenum "
                       +" left join BC_SITE_INFO t3 on t1.station_id=t3.exp_no left join BC_SITE_POLL  t4 on t3.exp_no=t4.site_id "
                       +" where t1.WWTP_ID='"+WWTPID+"' and t3.flow_type='"+flowType+"' and t4.name='011' "
                       +" and t1.CREATE_TIME >= to_date('"+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		//其他项目的总数语句
		String sql2="select t1.name from BC_SITE_POLL t1 left join BC_SITE_INFO t2 on t1.site_id=t2.exp_no where t2.WWTP_ID='"
				   +WWTPID+"'and t2.flow_type='"+flowType+"' and t1.name!='011' ";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		List<RowBase> listcod = DataUtil.getSelectRows(sql1, parms);
		String codstr="";
		String bt="";
		String et="";
		int h=0;//相差几个小时
		int sumh=0;//总共故障时间
		if(listcod.size()>0){
			for(int i=0;i<listcod.size();i++){
				bt=listcod.get(i).getValue("BEGIN_TIME").toString();
				et=listcod.get(i).getValue("END_TIME").toString();
				h=Integer.parseInt(String.valueOf(getDistanceTime(bt,et)));
				sumh+=h;
			}
			num=hour/sumh;
			codstr=num+"小时/次";
		}
		else{
			codstr="无";
		}
		
		/**计算其他项目开始**/
		String sql3 ="";
		String astr="";
		int allsum=0;//其他项目运转率之和
		int finalresult=0;//其他项目平均值
		String otstr="";
		List<RowBase> list = DataUtil.getSelectRows(sql2, parms);
		int asum=list.size();//总数
		sumh=0;
		if(asum>0){
		for(int i=0;i<list.size();i++){
			 astr=list.get(i).getValue("NAME").toString();
			 sql3 = "select t1.begin_time,t1.end_time from    OP_FAILURE_REPAIR t1 left join BC_SITE_DEVICE_RPT  t2  on t1.DEVICE_NUMBER=t2.device_typenum "
                    +" left join BC_SITE_INFO t3 on t1.station_id=t3.exp_no left join BC_SITE_POLL  t4 on t3.exp_no=t4.site_id "
                    +" where t1.WWTP_ID='"+WWTPID+"' and t3.flow_type='"+flowType+"' and t4.name='"+astr
                    +"' and t1.CREATE_TIME >= to_date('"+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
			 List<RowBase> listot = DataUtil.getSelectRows(sql3, parms);
			 if(listot.size()>0){
			 for(int j=0;j<listot.size();j++){
					bt=listcod.get(j).getValue("BEGIN_TIME").toString();
					et=listcod.get(j).getValue("END_TIME").toString();
					h=Integer.parseInt(String.valueOf(getDistanceTime(bt,et)));
					sumh+=h;
				}
			 num=hour/sumh;//每个项目的故障率多少小时/次
			 allsum+=num;//所有项目故障率之和
			}
			 else{
				 asum-=1;//每有一项为0,减掉一项
			 }
		}
		if(asum>0){
			finalresult=allsum/asum;
		}
		if(finalresult<1){
			otstr="无";
		}
		else{
			otstr=finalresult+"小时/次";
		 }
		}
		else{
			otstr="无";
		}
		/**计算其他项目结束***/
		HashMap<String, String> hdata1 = new HashMap<>();
		hdata1.put("SUM", codstr);
		hdata1.put("OTSUM", otstr);
		List<HashMap<String, String>> staticList = new ArrayList<>();
		staticList.add(hdata1);
		JSONArray staticdata=JSONArray.fromObject(staticList);
		JSONObject resultJson=new JSONObject();
		resultJson.put("data", staticdata);
		outString(resultJson.toString());
	}
	/**
	 * 获取设备运转率记录
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getSbyzDetail")
	public void getSbyzDetail(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String yearValue= RequestUnit.getParameter("yearValue");
		String quarterValue= RequestUnit.getParameter("quarterValue");
		String flowType=RequestUnit.getParameter("flowType");
		String type=RequestUnit.getParameter("TYPE");
		String endtime="";
		String satrttime="";
		if(quarterValue.equals("1")){
			satrttime=yearValue+"-01-01 00:00:00";
			endtime=yearValue+"-03-31 23:59:59";
		}
		if(quarterValue.equals("2")){
			satrttime=yearValue+"-04-01 00:00:00";
			endtime=yearValue+"-06-30 23:59:59";
		}
		if(quarterValue.equals("3")){
			satrttime=yearValue+"-07-01 00:00:00";
			endtime=yearValue+"-09-30 23:59:59";
		}
		if(quarterValue.equals("4")){
			satrttime=yearValue+"-10-01 00:00:00";
			endtime=yearValue+"-12-31 23:59:59";
		}
		String sql="";
		if(type.equals("A")){
			 sql = "select t1.*,t3.name from    OP_FAILURE_REPAIR t1 left join BC_SITE_DEVICE_RPT  t2  on t1.DEVICE_NUMBER=t2.device_typenum "
                    +" left join BC_SITE_INFO t3 on t1.station_id=t3.exp_no left join BC_SITE_POLL  t4 on t3.exp_no=t4.site_id "
                    +" where t1.WWTP_ID='"+WWTPID+"' and t3.flow_type='"+flowType+"' and t4.name='011' "
                    +" and t1.CREATE_TIME >= to_date('"+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		}
		if(type.equals("B")){
			 sql = "select t1.*,t3.name from  OP_FAILURE_REPAIR t1 left join BC_SITE_DEVICE_RPT  t2  on t1.DEVICE_NUMBER=t2.device_typenum "
	                    +" left join BC_SITE_INFO t3 on t1.station_id=t3.exp_no left join BC_SITE_POLL  t4 on t3.exp_no=t4.site_id "
	                    +" where t1.WWTP_ID='"+WWTPID+"' and t3.flow_type='"+flowType+"' and t4.name!='011' "
	                    +" and t1.CREATE_TIME >= to_date('"+satrttime+"','yyyy-mm-dd hh24:mi:ss')"+" and t1.CREATE_TIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";
		}
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("TASKQUERYDIC");
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		String result = DataUtil.getPageSelectJson(sql, parms, pTable);
		outString(result);
	}
	/**
	 * 获取通信稳定性数据
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/gettxwdxList")
	public void gettxwdxList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String yearValue= RequestUnit.getParameter("yearValue");
		String quarterValue= RequestUnit.getParameter("quarterValue");
		String flowType=RequestUnit.getParameter("flowType");
		String endtime="";
		String satrttime="";
		long num=0;
		 int num1=0;
		 int num2=0;
		 int num3=0;
		 int second=0;
		 int a=0;
		 int b=1;
		 int c=2;
		if(quarterValue.equals("1")){
			satrttime=yearValue+"-01-01 00:00:00";
			endtime=yearValue+"-03-31 23:59:59";
			a=0;
			b=1;
			c=2;
		}
		if(quarterValue.equals("2")){
			satrttime=yearValue+"-04-01 00:00:00";
			endtime=yearValue+"-06-30 23:59:59";
			a=3;
			b=4;
			c=5;
		}
		if(quarterValue.equals("3")){
			satrttime=yearValue+"-07-01 00:00:00";
			endtime=yearValue+"-09-30 23:59:59";
			a=6;
			b=7;
			c=8;
		}
		if(quarterValue.equals("4")){
			satrttime=yearValue+"-10-01 00:00:00";
			endtime=yearValue+"-12-31 23:59:59";
			a=9;
			b=10;
			c=11;
			
		}
		num1=getMonthDay(yearValue,a);
		num2=getMonthDay(yearValue,b);
		num3=getMonthDay(yearValue,c);
		//每个季度秒数
		second=(num1+num2+num3)*24*60*60;
		//每30秒一条数据，应上传数据数量
		int allsum=second/30;
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		/***计算实际上传数据 start***/
		String sql1="select t1.qn from monitor_data t1 left join BC_COLLECTION_INFO t2 on t1.mn=t2.DEVICE_NUM left join BC_SITE_INFO t3 on t2.SITE_ID=t3.exp_no "
				+" where t3.wwtp_id='"+WWTPID+"' and t3.flow_type='"+flowType+"' and t1.datatime >= to_date('"+satrttime+"','yyyy-mm-dd hh24:mi:ss')"
				+" and t1.datatime <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss') group by t1.qn";
		 List<RowBase> list = DataUtil.getSelectRows(sql1, parms);
		 int truesum=list.size();
		 long per=(truesum/allsum)*100;//通信稳定性数据传输率
		/***计算实际上传数据 end***/
		 String bt="";
		 String et="";
		 long h=0;
		 int allnum=(num1+num2+num3)*24;
		 num=allnum;
		 String sj="";
		 /***计算数采仪在线率 start***/
		  String sql2="select t1.* from MONITOR_ABNORMAL t1 left join BC_COLLECTION_INFO t2 on t1.mn=t2.DEVICE_NUM left join BC_SITE_INFO t3 on t2.SITE_ID=t3.exp_no "
					+" where t3.wwtp_id='"+WWTPID+"' and t3.flow_type='"+flowType+"' and t1.CREATETIME >= to_date('"+satrttime+"','yyyy-mm-dd hh24:mi:ss')"
							+" and t1.CREATETIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss')";;
		  List<RowBase> listhour = DataUtil.getSelectRows(sql2, parms);
		  if(listhour.size()>0){
				 for(int j=0;j<listhour.size();j++){
						bt=listhour.get(j).getValue("OFFLINE_TIME").toString();
						et=listhour.get(j).getValue("ONLINE_TIME").toString();
						if(!bt.equals("")&&bt!=null&&!et.equals("")&&et!=null){
							h=Long.parseLong(String.valueOf(getDistanceTime(bt,et)));
							num-=h;
						}
						
					}
				  sj=num/allnum+"%";
				}
		  else{
			  sj="100%";
		  }
		  //计算掉线时间
		 /***计算数采仪在线率 end***/
		 HashMap<String, String> hdata = new HashMap<>();
			hdata.put("SJZXL", sj);
			hdata.put("SJWDX", per+"%");
			List<HashMap<String, String>> staticList = new ArrayList<>();
			staticList.add(hdata);
			JSONArray staticdata=JSONArray.fromObject(staticList);
			JSONObject resultJson=new JSONObject();
			resultJson.put("data", staticdata);
			outString(resultJson.toString());
	}
	/**
	 * 获取通信稳定性记录
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getTxwdxZxlDetail")
	public void getTxwdxZxlDetail(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String yearValue= RequestUnit.getParameter("yearValue");
		String quarterValue= RequestUnit.getParameter("quarterValue");
		String flowType=RequestUnit.getParameter("flowType");
		String endtime="";
		String satrttime="";
		if(quarterValue.equals("1")){
			satrttime=yearValue+"-01-01 00:00:00";
			endtime=yearValue+"-03-31 23:59:59";
		}
		if(quarterValue.equals("2")){
			satrttime=yearValue+"-04-01 00:00:00";
			endtime=yearValue+"-06-30 23:59:59";
		}
		if(quarterValue.equals("3")){
			satrttime=yearValue+"-07-01 00:00:00";
			endtime=yearValue+"-09-30 23:59:59";
		}
		if(quarterValue.equals("4")){
			satrttime=yearValue+"-10-01 00:00:00";
			endtime=yearValue+"-12-31 23:59:59";
		}
		String sql="";
		//if(type.equals("A")){
			 sql="select t1.*,t3.NAME from monitor_data t1 left join BC_COLLECTION_INFO t2 on  t1.mn=t2.DEVICE_NUM  left join BC_SITE_INFO t3 on t2.SITE_ID=t3.exp_no "
					+" where t3.wwtp_id='"+WWTPID+"' and t3.flow_type='"+flowType+"' and t1.datatime >= to_date('"+satrttime+"','yyyy-mm-dd hh24:mi:ss')"
					+" and t1.datatime <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss') ";
		//}
		/*if(type.equals("B")){
			 sql = "select t1.* from monitor_data t1 left join BC_SITE_DEVICE_RPT  t2 on t1.mn=t2.DEVICE_TYPENUM left join BC_SITE_INFO t3 on t2.monitor_point=t3.exp_no "
						+" where t3.wwtp_id='"+WWTPID+"' and t3.flow_type='"+flowType+"' and t1.CREATETIME >= to_date('"+satrttime+"','yyyy-mm-dd hh24:mi:ss')"
						+" and t1.CREATETIME <= to_date('"+endtime+"','yyyy-mm-dd hh24:mi:ss') ";
		}*/
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("TASKQUERYDIC");
		String result = DataUtil.getPageSelectJson(sql, parms, pTable);
		outString(result);
	}
	/**
	 * 获取质量保证和质量控制-操作人员记录
	 * wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getUserData")
	public void getUserData(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String flowType=RequestUnit.getParameter("flowType");
		String sql=" select t5.* from BC_SITE_INFO t1 left join operation_group_station_asso t2 on t1.exp_no=t2.station_id"
				+" left join OC_GROUP t3 on t2.operation_group_id=t3.guid left join OC_GROUP_ASSO t4 on t3.guid=t4.group_id left join safe_user t5 on t4.user_id=t5.s_userid"
				+" where t1.wwtp_id='"+WWTPID+"' and t1.flow_type='"+flowType+"'";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		String result = DataUtil.getPageSelectJson(sql, parms);
		outString(result);
	}
	/**
	 * 获取站点名称
	 *  wangl
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getStationData")
	public void getStationData(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String WWTPID=RequestUnit.getParameter("WWTPID");
		String flowType=RequestUnit.getParameter("flowType");
		String sql="select * from BC_SITE_INFO where  WWTP_ID='"+WWTPID+"' and flow_type='"+flowType+"'";
		List<GlobalParameter> parms = new ArrayList<GlobalParameter>();
		String result = DataUtil.getPageSelectJson(sql, parms);
		outString(result);
	}
	/**
     * 获取某年某月有几天
     * @param str1 时间参数 1 格式：2015
     * @param int 时间参数 2 格式：0
     * @return String 返回值为：
     */
	public static int getMonthDay(String str,int n){
		 Calendar c = Calendar.getInstance();
		 c.set(Calendar.YEAR, Integer.parseInt(str)); 
		 c.set(Calendar.MONTH, n);
		int	num=c.getActualMaximum(Calendar.DAY_OF_MONTH);
		return num;
	}
	/**
	 * 获取某月的最后一天
	 * @param year
	 * @param month
	 * @return
	 */
    public String getLastDayOfMonth(int year,int month)
    {
        Calendar cal = Calendar.getInstance();
        //设置年份
        cal.set(Calendar.YEAR,year);
        //设置月份
        cal.set(Calendar.MONTH, month-1);
        //获取某月最大天数
        int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        //设置日历中月份的最大天数
        cal.set(Calendar.DAY_OF_MONTH, lastDay);
        //格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String lastDayOfMonth = sdf.format(cal.getTime());
         
        return lastDayOfMonth;
    }
    /**
	 * 获取某月的第一天
	 * @param year
	 * @param month
	 * @return
	 */
    public String getFirstDayOfMonth(int year,int month)
    {
        Calendar cal = Calendar.getInstance();
        //设置年份
        cal.set(Calendar.YEAR,year);
        //设置月份
        cal.set(Calendar.MONTH, month-1);
        //获取某月最大天数
        int firstDay = cal.getActualMinimum(Calendar.DAY_OF_MONTH);
        //设置日历中月份的最大天数
        cal.set(Calendar.DAY_OF_MONTH, firstDay);
        //格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String lastDayOfMonth = sdf.format(cal.getTime());
         
        return lastDayOfMonth;
    }
	/**
     * 两个时间相差距离多少小时
     * @param str1 时间参数 1 格式：1990-01-01 12:00:00
     * @param str2 时间参数 2 格式：2009-01-01 12:00:00
     * @return String 返回值为：
     */
    public static long getDistanceTime(String str1, String str2) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date one;
        Date two;
        long hour = 0;
        try {
            one = df.parse(str1);
            two = df.parse(str2);
            long time1 = one.getTime();
            long time2 = two.getTime();
            long diff ;
            if(time1<time2) {
                diff = time2 - time1;
            } else {
                diff = time1 - time2;
            }
            hour=diff/(60 * 60 * 1000);
            //day = diff / (24 * 60 * 60 * 1000);//相差天数
           // min = diff / (60 * 1000) ;//相差分钟
           // sec = diff/1000;//相差秒
        } catch (ParseException e) {
            e.printStackTrace();
        }
       
        return hour;
       
    }
    
    /**
	 * 获取站点有效性统计
	 * kbb
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getStationValidateStatisticsTotal")
	public void getStationValidateStatisticsRst(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		
		HashMap<String,String> resqMap = convertHttpServletRequest(resq);
		
		// 1、获取站点关联的监测数据参数
		List<RowBase> paramList = getStationParamList(resqMap);
		if (paramList.size() < 1)
			return;
		
		// 2、遍历参数并获取每个监测项的有效性
		for (int i=0; i<paramList.size(); i++)
		{
			//List<HashMap<String, String>> dataValidateList = getParamValidateStatisticsRst(resq, res);
		}
		
		// 3、返回站点下监测数据参数有效性列表
	}
	
	/**
	 * 获取参数有效性统计
	 * kbb
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getParamValidateStatisticsTotal")
	public void getParamValidateStatisticsRst(HttpServletRequest resq, HttpServletResponse res) throws Exception {
			
		// 1、获取参数关联的事件
			
		// 2、遍历事件并获取每个事件的有效性
		
		// 3、返回参数包含的事件有效性列表
	}
	
	/**
	 * 获取事件有效性统计
	 * kbb
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getEventValidateStatisticsTotal")
	public void getEventValidateStatisticsRst(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		
		// 1、获取事件关联的合并测量记录
		
		// 2、获取事件关联的任务记录
		
		// 3、判定事件的有效性
	}
	
	/**
	 * 获取站点数据参数列表
	 * kbb
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	public List<RowBase> getStationParamList(HashMap<String,String> resqMap) throws Exception {
		
		String strWWTP_ID = resqMap.get("WWTP_ID");
		String strSTATION_ID = resqMap.get("STATION_ID");
		String strFLOW_NAME = resqMap.get("FLOW_NAME");

		String[] arrWWTP_ID = strWWTP_ID.split(",");
		String[] arrSTATION_ID = strSTATION_ID.split(",");
		String[] arrFLOW_NAME = strFLOW_NAME.split(",");
					
		String strSQL = " select t1.*,  "
				+ " d1.S_DOMAINCAPTION as POLLUTANTS_NAME, d2.S_DOMAINCAPTION as FLOW_TYPE_NAME "
				+ " from BC_SITE_POLL t1 "
				+ " left join BC_ENTERPRISE_ATTR t2 on t1.WSCLC_ID = t2.EXP_NO  "
				+ " left join BC_SITE_INFO t3 on t1.SITE_ID = t3.EXP_NO "
				+ " left join DATA_DEFULATDOMAIN d1 on ( d1.S_DOMAINNAME = 'MONITOR_PARAM' AND d1.S_DOMAINCODE = t1.NAME ) "
				+ " left join DATA_DEFULATDOMAIN d2 on ( d2.S_DOMAINNAME = 'STATION_FLOW_TYPE' AND d2.S_DOMAINCODE = t3.FLOW_TYPE ) "
				+ " where 1=1";
		
		if (strWWTP_ID.length()>0 && arrWWTP_ID.length>0){
			strSQL=strSQL + " AND ( ";
			
			for (int i=0; i<arrWWTP_ID.length; i++){
				if(i<arrWWTP_ID.length-1)
					strSQL = strSQL + "t1.WSCLC_ID LIKE '%"+arrWWTP_ID[i]+"%' OR ";
				else
					strSQL = strSQL + "t1.WSCLC_ID LIKE '"+arrWWTP_ID[i]+"' ";
			}
			
			strSQL=strSQL + " )";
		}
		
		if (strSTATION_ID.length()>0 && arrSTATION_ID.length>0){
			strSQL=strSQL + " AND ( ";
			
			for (int i=0; i<arrSTATION_ID.length; i++){
				if(i<arrSTATION_ID.length-1)
					strSQL = strSQL + "t1.SITE_ID LIKE '%"+arrSTATION_ID[i]+"%' OR ";
				else
					strSQL = strSQL + "t1.SITE_ID LIKE '%"+arrSTATION_ID[i]+"%' ";
			}
			
			strSQL=strSQL + " )";
		}
		
		if (strFLOW_NAME.length()>0 && arrFLOW_NAME.length>0){
			strSQL=strSQL + " AND ( ";
			
			for (int i=0; i<arrFLOW_NAME.length; i++){
				if(i<arrFLOW_NAME.length-1)
					strSQL = strSQL + "t3.FLOW_TYPE = '"+arrFLOW_NAME[i]+"' OR ";
				else
					strSQL = strSQL + "t3.FLOW_TYPE = '"+arrFLOW_NAME[i]+"' ";
			}
			
			strSQL=strSQL + " )";
		}
		
		ITableFactory tableFactory = (ITableFactory) SpringBeanFactory.getBean("TableFactory");
		ITable pTable = tableFactory.openTable("TASKQUERYDIC");
		List<GlobalParameter> param = new ArrayList<GlobalParameter>();
		List<RowBase> paramList = DataUtil.getSelectRows(strSQL, param,pTable);
		
		return paramList;
	}
	
	/**
	 * 获取参数事件列表
	 * kbb
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	public void getParamEventList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		
	}
	
	
	/**
	 * 获取事件合并记录
	 * kbb
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getMergeDataList")
	public void getMergeDataList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		
		// 1、获取事件关联的数据记录
		
		// 2、合并数据记录
		// 2.1 三条记录合并为一条
		// 2.2获取上次测试日期
		
		// 3、返回合并记录
	}
	
	/**
	 * 获取事件任务记录
	 * kbb
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getTaskRcdList")
	public void getTaskRcdList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		
	}
	
	
	/**
	 * 获取事件数据记录
	 * kbb
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getDataRcdList")
	public void getDataRcdList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		
	}
	
	/**
	 * 获取最近记录
	 * kbb
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	public void getLastestDataRcd(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		
	}
	
	/**
	 * 转换参数
	 * kbb
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	public HashMap<String, String> convertHttpServletRequest(HttpServletRequest resq) throws Exception {
		
		HashMap<String, String> resqMap = new HashMap<>();
		
		resqMap.put("JOB_ID", RequestUnit.getString("JOB_ID"));
		resqMap.put("TASK_ID", RequestUnit.getString("TASK_ID"));
		resqMap.put("WWTP_ID", RequestUnit.getString("WWTP_ID"));
		resqMap.put("STATION_ID", RequestUnit.getString("STATION_ID"));
		resqMap.put("FLOW_NAME", RequestUnit.getString("FLOW_NAME"));
		resqMap.put("MEASURE_ITEM", RequestUnit.getString("MEASURE_ITEM"));
		resqMap.put("MEASURE_PERSON", RequestUnit.getString("MEASURE_PERSON"));
		resqMap.put("MEASURE_CONCLUSION", RequestUnit.getString("MEASURE_CONCLUSION"));
		resqMap.put("MEASURE_YEAR", RequestUnit.getString("MEASURE_YEAR"));
		resqMap.put("MEASURE_START_MONTH", RequestUnit.getString("MEASURE_START_MONTH"));
		resqMap.put("MEASURE_END_MONTH", RequestUnit.getString("MEASURE_END_MONTH"));
		resqMap.put("MEASURE_TOLERANCE", RequestUnit.getString("MEASURE_TOLERANCE"));	
	
		return resqMap;
	}
	
	/**
	 * 获取人工监测记录
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getManualMonitorList")
	public void getManualMonitorList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String wwtpid = RequestUnit.getParameter("WWTP_ID");
		String flowType = RequestUnit.getParameter("FLOW_NAME");
		String station_id = getStationId(wwtpid,flowType);
		
		List<GlobalParameter> listParam = new ArrayList<GlobalParameter>();
		if(StringUtil.IsNotNullOrEmpty(station_id)){
			listParam.add(new GlobalParameter("station_id", station_id));
		}else{
			return;
		}
		
		int year = Integer.parseInt(RequestUnit.getParameter("MEASURE_YEAR"));
		int start_month = Integer.parseInt(RequestUnit.getParameter("MEASURE_START_MONTH"));
		int end_month = Integer.parseInt(RequestUnit.getParameter("MEASURE_END_MONTH"));
		
		String start = getFirstDayOfMonth(year,start_month);
		String end = getLastDayOfMonth(year,end_month);
		
		String sql = "select t.start_time,ofr.* from OP_TASK t left join operation_artificial_monitor ofr on t.task_code = ofr.task_code"
				+ " where t.job_id = (select GUID from operation_job j where j.job_name='人工监测' and rownum=1)"
				+ " and t.station_id=@station_id"
				+ " and t.start_time >= to_date('" + start + " 00:00:00', 'YYYY-MM-DD HH24:MI:SS')"
				+ " and t.start_time <= to_date('" + end + " 23:59:59', 'YYYY-MM-DD HH24:MI:SS')";
	
		String result = DataUtil.getPageSelectJson(sql, listParam);
		outString(result);
	}
	
	/**
	 * 获取设备维修记录
	 * @param resq
	 * @param res
	 * @throws Exception
	 */
	@RequestMapping(value = "/getDeviceRepairList")
	public void getDeviceRepairList(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String wwtpid = RequestUnit.getParameter("WWTP_ID");
		String flowType = RequestUnit.getParameter("FLOW_NAME");
		String station_id = getStationId(wwtpid,flowType);
		
		List<GlobalParameter> listParam = new ArrayList<GlobalParameter>();
		if(StringUtil.IsNotNullOrEmpty(station_id)){
			listParam.add(new GlobalParameter("station_id", station_id));
		}else{
			return;
		}
		
		int year = Integer.parseInt(RequestUnit.getParameter("MEASURE_YEAR"));
		int start_month = Integer.parseInt(RequestUnit.getParameter("MEASURE_START_MONTH"));
		int end_month = Integer.parseInt(RequestUnit.getParameter("MEASURE_END_MONTH"));
		
		String start = getFirstDayOfMonth(year,start_month);
		String end = getLastDayOfMonth(year,end_month);
		
		String sql = "select t.start_time,ofr.* from OP_TASK t left join OP_FAILURE_REPAIR ofr on t.task_code = ofr.task_id"
				+ " where t.job_id = (select GUID from operation_job j where j.job_name='设备故障及维修' and rownum=1)"
				+ " and t.station_id=@station_id"
				+ " and t.start_time >= to_date('" + start + " 00:00:00', 'YYYY-MM-DD HH24:MI:SS')"
				+ " and t.start_time <= to_date('" + end + " 23:59:59', 'YYYY-MM-DD HH24:MI:SS')";
	
		String result = DataUtil.getPageSelectJson(sql, listParam);
		outString(result);
	}
	/**
	 * 获取季度有效审核信息
	 */
	@RequestMapping(value = "/getCheckData")
	public void getCheckData(HttpServletRequest resq, HttpServletResponse res) throws Exception {
		String STATION_CODE = RequestUnit.getParameter("STATION_CODE");
		String WWTP_ID = RequestUnit.getParameter("WWTP_ID");
		String st = RequestUnit.getParameter("START_TIME");
		String et = RequestUnit.getParameter("END_TIME");
		String waterType = RequestUnit.getParameter("waterType");
		
		List<GlobalParameter> listParam = new ArrayList<GlobalParameter>();
		String sql = "select t2.name,t1.* from DATAVALIDATION_QUARTER t1 left join BC_SITE_INFO t2 on t1.station_code=t2.exp_no where 1=1 ";
		 if (STATION_CODE != null && !STATION_CODE.equals("")) {
        	 sql+=" and t1.STATION_CODE='"+STATION_CODE+"'";
		}
		 if (WWTP_ID != null && !WWTP_ID.equals("")) {
        	 sql+=" and t2.WWTP_ID='"+WWTP_ID+"'";
		}
		 if (st != null && !st.equals("")) {
        	 sql+=" and t1.et >=to_date('"+st+"','yyyy-MM-dd')";
		}
		 if (et != null && !et.equals("")) {
        	 sql+=" and t1.et <= to_date('"+et+"','yyyy-MM-dd')";
		}
		 if (waterType != null && !waterType.equals("")) {
        	 sql+=" and t2.STATION_CATEGORY='"+waterType+"'";
		}
		String result = DataUtil.getPageSelectJson(sql, listParam);
		outString(result);
	}
}
